#include<iostream>
using namespace std;
const int N = 5010;
int n;
int dis[N];
int sum;
int count1;
void dfs1(int step)
{
	if (step == 11) {
		if (sum == n) {
			count1++;
		}
		return;
	}
	if (sum > n) {
		return;
	}
	for (int i = 1; i <= 3; i++) {
		dis[step] = i;
		sum += i;
		dfs1(step + 1);
		dis[step] = 0;
		sum -= i;
	}
}
void dfs2(int step)
{
	if (step == 11) {
		if (sum == n) {
			for (int j = 1; j <= 10; j++) {
				cout << dis[j] << " ";
			}
			cout << endl;
			count1++;
		}
		return;
	}
	if (sum > n) {
		return;
	}
	for (int i = 1; i <= 3; i++) {
		dis[step] = i;
		sum += i;
		dfs2(step + 1);
		dis[step] = 0;
		sum -= i;
	}
}
int main()
{
	cin >> n;
	dfs1(1);
	cout << count1 << endl;
	dfs2(1);
	return 0;
}